import json


class MapLst:
    def __init__(self, dic, lst):
        self.dic = dic
        self.lst = lst


def json_loader(json_file_name):
    file_path = f'scripts/data/json/{json_file_name}.json'
    with open(file_path, 'r', encoding='utf-8') as file:
        lst = json.loads(file.read())
        dic = {}
        for e in lst:
            dic[e['id']] = e
        return MapLst(dic, lst)


tb_chicken = json_loader('tbchicken')
tb_chicken_quality = json_loader('tbchickenquality')
tb_farm = json_loader('tbfarm')



quality_2_chickens = {}
for e in tb_chicken.lst:
    quality_2_chickens.setdefault(e['quality'], []).append(e)
